﻿<Window x:Class="FileMatcherApp.Views.DuplicatesSummary"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:commands="clr-namespace:FileMatcherApp.Commands"
        xmlns:local="clr-namespace:FileMatcherApp"
        xmlns:models="clr-namespace:FileMatcherApp.Models"
        Title="{x:Static local:Strings.SumaryWindowTitle}" Height="536" Width="679" ResizeMode="CanResizeWithGrip"
        Closing="Window_Closing">
    <Window.CommandBindings>
        <CommandBinding Command="commands:CommandLibrary.OpenFolder" CanExecute="OnCanExecuteOpenFolder"
                        Executed="OnExecuteOpenFolder"/>
        <CommandBinding Command="commands:CommandLibrary.Delete" CanExecute="OnCanExecuteDelete"
                        Executed="OnExecuteDelete" />
        <CommandBinding Command="commands:CommandLibrary.Undelete" CanExecute="OnCanExecuteUndelete"
                        Executed="OnExecuteUndelete" />
        <CommandBinding Command="commands:CommandLibrary.Shortcut" CanExecute="OnCanExecuteShortcut"
                        Executed="OnExecuteShortcut"/>
    </Window.CommandBindings>
    <DockPanel LastChildFill="True">
        <Menu HorizontalAlignment="Left" Height="24" VerticalAlignment="Top" Grid.Row ="0" Margin="0,0,0,0"
              DockPanel.Dock="Top">
            <MenuItem Header="{x:Static local:Strings.MiFile}">
                <MenuItem.Items>
                    <MenuItem Header="{x:Static local:Strings.MiClose}" Click="MiCloseOnClick"/>
                </MenuItem.Items>
            </MenuItem>
            <MenuItem Header="{x:Static local:Strings.MiView}">
                <MenuItem.Items>
                    <MenuItem Name="MiFilter" Header="{x:Static local:Strings.MiFilter}" Click="MiFilter_OnClick"></MenuItem>
                </MenuItem.Items>
            </MenuItem>
            <MenuItem Header="{x:Static local:Strings.MiEdit}">
                <MenuItem.Items>
                    <MenuItem Name="MiUndo" Header="{x:Static local:Strings.MiUndo}" Click="MiUndo_OnClick" IsEnabled="{Binding Path=Undoable}"/>
                    <MenuItem Name="MiRedo" Header="{x:Static local:Strings.MiRedo}" Click="MiRedo_OnClick" IsEnabled="{Binding Path=Redoable}"/>
                    <MenuItem Name="MiApply" Header="{x:Static local:Strings.MiApply}" Click="MiApplyOnClick"></MenuItem>
                </MenuItem.Items>
            </MenuItem>
            <MenuItem Header="{x:Static local:Strings.MiSearch}">
                <MenuItem.Items>
                    <MenuItem Name="MiPause" Header="{Binding PauseButtonTitle}" Click="MiPauseOnClick" IsEnabled="{Binding IsSearching}"></MenuItem>
                    <MenuItem Name="MiStop" Header="{x:Static local:Strings.MiStop}" Click="MiStopOnClick" IsEnabled="{Binding IsSearching}"></MenuItem>
                </MenuItem.Items>
            </MenuItem>
            <MenuItem Header="{x:Static local:Strings.MiActions}">
                <MenuItem.Items>
                    <MenuItem Name="MiDeleteSelected" Header="{x:Static local:Strings.MiDeleteSelected}" Command="commands:CommandLibrary.Delete"></MenuItem>
                    <MenuItem Name="MiUndeleteSelected" Header="{x:Static local:Strings.MiUndeleteSelected}" Command="commands:CommandLibrary.Undelete"></MenuItem>
                    <MenuItem Name="MiPickRepresentative" Header="{x:Static local:Strings.MiPickRepresentative}" IsCheckable="True" Click="MiPickRepresentative_OnClick"></MenuItem>
                    <MenuItem Name="MiPickSurvivor" Header="{x:Static local:Strings.MiDeleteUnselected}" IsCheckable="True" Click="MiPickSurvivor_OnClick"></MenuItem>
                </MenuItem.Items>
            </MenuItem>
            <MenuItem Header="{x:Static local:Strings.MiHelp}">
                <MenuItem.Items>
                    <MenuItem Name="MiOnlineHelp" Header="{x:Static local:Strings.MiOnlineHelp}" Click="MiOnlineHelp_OnClick"/>
                </MenuItem.Items>
            </MenuItem>
        </Menu>
        <DockPanel LastChildFill="True">
            <DockPanel DockPanel.Dock="Top" Height="28">
                <Button x:Name="BtnUndelSel" Content="{x:Static local:Strings.UndeleteSelected}" HorizontalAlignment="Left"
                VerticalAlignment="Top" Width="106" Height="20" DockPanel.Dock="Right" Margin="10,4,10,0"
                Command="commands:CommandLibrary.Undelete"/>
                <Button Name="BtnDelSel" Content="{x:Static local:Strings.DeleteSelected}" HorizontalAlignment="Left" Margin="10,4,10,0"
                        VerticalAlignment="Top" Width="106" Height="20" Command="commands:CommandLibrary.Delete" DockPanel.Dock="Right"/>
                <Label Content="{x:Static local:Strings.DuplicateFilesFound}" HorizontalAlignment="Left" Margin="10,4,0,0" VerticalAlignment="Top" 
                       DockPanel.Dock="Left" Height="26" Width="238"/>
            </DockPanel>
            <StatusBar DockPanel.Dock="Bottom" Height="20">
                <DockPanel LastChildFill="True">
                    <ProgressBar Width="100" Maximum="100" Value="{Binding ProgressPercentage}"></ProgressBar>
                    <TextBlock Text="{Binding Status}"></TextBlock>
                </DockPanel>
            </StatusBar>
            <ListView Name="LvRedundant" Margin="10,0,0,10" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                  ItemsSource="{Binding Path=IdenticalFiles}" 
                    DataContextChanged="LvRedundantOnDataContextChanged" 
                      GridViewColumnHeader.Click="LvRedundantGridViewColumnHeaderOnClick"
                      SelectionChanged="LvRedundant_OnSelectionChanged" MouseDoubleClick="LvRedundant_OnMouseDoubleClick">
                <ListView.Resources>
                    <DataTemplate x:Key="StateTemplate" DataType="models:FileInfoEx">
                        <TextBlock Text="{Binding State}">
                            <TextBlock.ToolTip>
                                <ToolTip>
                                    <TextBlock Text="{Binding ShortcutTooltip}"/>
                                </ToolTip>
                            </TextBlock.ToolTip>
                        </TextBlock>
                    </DataTemplate>
                </ListView.Resources>
                <ListView.GroupStyle>
                    <GroupStyle>
                        <GroupStyle.HeaderTemplate>
                            <DataTemplate>
                                <TextBlock FontWeight="Bold" FontSize="15"
                                       Text="{Binding Path=Name}" Foreground="Blue" Background="Green"/>
                            </DataTemplate>
                        </GroupStyle.HeaderTemplate>
                    </GroupStyle>
                </ListView.GroupStyle>
                <ListView.ItemContainerStyle>
                    <Style TargetType="{x:Type ListViewItem}">
                        <Setter Property="BorderThickness" Value="1" />
                        <Setter Property="Width" Value="Auto" />
                        <Setter Property="FontSize" Value="12.4"  />
                        <Setter Property="Foreground" Value="Black" />
                        <Setter Property="Background" Value="Transparent" />
                        <Setter Property="Margin" Value="0,0,0,0" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="{x:Type ListViewItem}">
                                    <TextBlock Background="{TemplateBinding Background}">
                                        <GridViewRowPresenter/>
                                    </TextBlock>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Background" Value="Yellow"/>
                            </Trigger>
                            <DataTrigger Binding="{Binding Path=IsSelectedToDelete}" Value="true">
                                <Setter Property="Foreground" Value="Gray"/>
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate TargetType="{x:Type ListViewItem}">
                                            <TextBlock x:Name="Tb" Background="{TemplateBinding Background}">
                                                <TextBlock.TextDecorations>
                                                    <TextDecoration Location="Strikethrough" PenOffset="-2" PenOffsetUnit="Pixel"/>
                                                </TextBlock.TextDecorations>
                                            <GridViewRowPresenter/>
                                            </TextBlock>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </ListView.ItemContainerStyle>
                <ListView.View>
                    <GridView>
                        <GridViewColumn Header="{x:Static local:Strings.HeaderName}" DisplayMemberBinding="{Binding Path=Name}" Width="100"/>
                        <GridViewColumn Header="{x:Static local:Strings.HeaderDirectory}" DisplayMemberBinding="{Binding Path=DirectoryName}" Width="360"/>
                        <GridViewColumn Header="{x:Static local:Strings.HeaderSize}" DisplayMemberBinding="{Binding Path=DisplayFileSize}" Width="80"/>
                        <GridViewColumn Header="{x:Static local:Strings.HeaderState}" CellTemplate="{StaticResource StateTemplate}" Width="80"/>
                    </GridView>
                </ListView.View>
                <ListView.ContextMenu>
                    <ContextMenu>
                        <MenuItem Command="commands:CommandLibrary.OpenFolder" Header="{x:Static local:Strings.MiOpenFileLocation}"/>
                        <MenuItem Command="commands:CommandLibrary.Delete" />
                        <MenuItem Command="commands:CommandLibrary.Undelete" />
                        <MenuItem Command="commands:CommandLibrary.Shortcut" />
                    </ContextMenu>
                </ListView.ContextMenu>
            </ListView>
        </DockPanel>
    </DockPanel>
</Window>
